% eyelid_script
%% Open the target folder
ny_folder = dir('notyet');
ny_folder = ny_folder(3:end);

%% For each image, open the corresponding iris file
for i = 1:length(ny_folder);
    disp(double(i)/length(ny_folder));
    filepath = fullfile('notyet',ny_folder(i).name);
    guesspath = fullfile('guesses',[ny_folder(i).name '.guess']);
    
    I = imread(filepath);
    [center,radius] = circularhough(I,.5,false);
    eyelid_points = detect_eyelid(I,[center(2) center(1)],radius,false);
    
    %[px, py] = circlepoints(radius);
    %figure(i); imshow(I); hold on; plot(py+center(2),px+center(1));
    
    %plot(eyelid_points(:,1),eyelid_points(:,2),'ro');
    
    data = zeros(11,3);
    data(1,:) = [center(2) center(1) radius];
    data(2:end,1:2) = eyelid_points;
    dlmwrite(guesspath, data, 'delimiter', '\t')
end